import React from "react";
import ProductList from "../components/ProductList";
import { connect } from "dva";

function Products({products,dispatch}) {

  let onDelete = (payload)=>{
    dispatch({
      type:"products/delete",
      payload
    })
  }

  return (
    <div>
      <ProductList products={products} onDelete={onDelete}></ProductList>
    </div>
  );
}

let mapStateToProps = ({ products }) => ({
  products,
});

export default connect(mapStateToProps)(Products);
